<script>
import api from '@/api/index'

export default {
  name: "index",
  data() {
    return {
      total: 0,
      tableData: [],
      queryParam: {
        pageSize: 5,
        pageNum: 1
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    handlerToDetail(row) {
      this.$router.push(`/guizhang/detail?id=${row.id}`)
    },
    async fetchData() {
      let data = await api.gui_zhang_List(this.queryParam);
      console.log('>>>>>>>>>>>data', data)
      this.tableData = data.records;
      this.total = data.total
    },
    handleCurrentChange(size) {
      this.queryParam.pageNum = size
      this.fetchData()
    },
    handleSizeChange(size) {
      this.queryParam.pageSize = size
      this.fetchData()
    }
  }
}
</script>

<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-table
            :data="tableData"
            style="width: 100%">
          <el-table-column
              prop="id"
              label="序号"
          >
          </el-table-column>
          <el-table-column
              show-overflow-tooltip
              prop="title"
              label="标题"
          >
            <template #default="{row}">
              <div class="cursor-pointer" @click="handlerToDetail(row)">{{ row.title }}</div>
            </template>
          </el-table-column>
          <el-table-column
              label="下载">
            <template #default="{row}">
              <div>

                <a :href="row.docUrl" target="_blank" class="px-2">下载文字版</a>
                <a :href="row.pdfUrl" target="_blank" class="px-2">下载图片版</a>
              </div>
            </template>
          </el-table-column>

        </el-table>
      </el-col>
      <el-col :span="24" class="mt-2 flex justify-center">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryParam.pageNum"
            :page-sizes="[5,10,20]"
            :page-size="queryParam.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped>

</style>
